#!/usr/local/bin/python3
# -*- coding: UTF-8 -*- 
import sys
import shutil
import os
# absolutePath=os.path.abspath("..")
outPath=os.getcwd()+"/sticker/sticker/"
# accessPath=sys.argv[1]

def find(path,accessPath):
    file = open( path, "r" )
    fhContent = file.readlines()
    file.close()
    for index,x in enumerate(fhContent):
        if  "require"in x:
            a=x.split("\"")
            print("复制 "+a[1]+" 文件")           
            shutil.copy(accessPath+a[1],outPath)
            find(accessPath+a[1],accessPath)
         
def copyModles(accessPath,luaName):
    print(accessPath)  
    if os.path.exists(accessPath+luaName+".lua"):
        shutil.copy(accessPath+luaName+".lua",outPath)
        # os.rename(outPath+"index.lua",outPath+"script.lua")
        find(accessPath+luaName+".lua",accessPath)
    elif os.path.exists(accessPath):
        shutil.copy(accessPath,outPath)
        find(accessPath,accessPath)
    else:
        print("不存在lua入口文件,无法搜寻modle"+"当前python位置:"+outPath)
            

        